'use strict';
//求租
const Controller = require('egg').Controller;

class LiveSeeController extends Controller {
    async index() {
        const {
            ctx
        } = this;
        ctx.body = 'hi, egg';
    }

    async gethouse() {
        const {
            ctx
        } = this;
        const data = await this.app.mysql.select('livesee');
        ctx.body = data;
    }

    async gethousetype() {
        const {
            ctx
        } = this;
        const {
            item
        } = ctx.query;
        console.log(item, 'item...');

        let type = null;
        let data = null;
        switch (item) {
            case '不限':
                type = 2;
                break;
            case '正在直播':
                type = 0;
                break;
            case '精彩回放':
                type = 1;
                break;
        }
        if (type == 2) {
            data = await this.app.mysql.select('livesee');
        } else {
            data = await this.app.mysql.select('livesee', {
                where: {
                    type
                }
            })
        }
        // console.log(data,'dara....');
        ctx.body = data;
    }

    //
    async gethousedetail() {
        const { ctx } = this;
    }

}

module.exports = LiveSeeController;